<template>
  <view class="page-body">
   <u-navbar :is-back="false" title="订单审核"
     title-size="30"
     :background="{background:'#2B88FE' }"
     title-color="#fff">
     <div class="head_icon">
       <u-icon @click="$api.handleBackTo"
         name="arrow-left" color="#fff"
         size="36">
       </u-icon>
       <u-icon @click="$api.handleHomeTo"
         name="home" color="#fff" size="36">
       </u-icon>
     </div>
   </u-navbar>
    <view class="clist x-row">
      <view class="x-col-center cname">
        订单金额
      </view>
        
      <view class="rmb x-col-center">
        {{detail.fMoney}} 元
      </view>
    </view>
	
	<view class="clist x-row">
	  <view class="x-col-center cname">
	    收款金额
	  </view>
	  <input placeholder="请输入" v-model="form.PayMoney " type="digit"
	    class="x-col x-col-center "></input>
	  <view class="rmb x-col-center">
	    元
	  </view>
	</view>
	<view class="h16">	
	</view>
 
 <view class="clist x-row">
   <view class="x-col-center cname">
     付款方式
   </view>
   <view class="upimg x-col-center">
     <picker @change="confirm($event)" :range="payTypes" range-key="label">
            {{payTypes[form.PayType].label}}
            <u-icon style="margin-left:10rpx" name="arrow-down-fill" color="#666" size="20">
            </u-icon>
          </picker>
   </view>
   
 </view>
 <view class="h16">	
 </view>
 
 
	<view class="clist x-row">
	  <view class="x-col-center cname">
	    抹零
	  </view>
	  <input placeholder="请输入" v-model="form.NoPay " type="digit"
	    class="x-col x-col-center "></input>
	  <view class="rmb x-col-center">
	    元
	  </view>
	</view>
	<view class="h16">	
	</view>

	
    <view class="infos whiteBg">
      <view class="clist x-row ">
        <view class="x-col-center cname" style="width: 300rpx;">
          订单备注（非必填）
        </view>
      </view>
      <textarea v-model="form.PayInfo" class="txt" placeholder="请在此输情况说明…"></textarea>
	<view class="h16">	
	</view>
	<view class="clist x-row">
	  <view class="x-col-center cname">
	    订单凭证
	  </view>
	</view>
	<u-upload ref="uUpload" :header="header" max-count="8" name="file" :action="action"
	  :auto-upload="true">
	</u-upload>


    </view>
 
	
	<div class="footer">
	  
	  <u-button type="primary"  @click="submit">提交</u-button>
	</div>
	
	
  </view>
</template>

<script>
export default {
  data() {
    return {
		payTypes: [
		  {
		    label: '现金',
		    value: 0
		  },
		  {
		    label: '企业微信',
		    value: 1
		  }, 
		  {
			 label: '银行转账',
			  value: 2
		  } 
		],
		
      form: {
	    OrderId: this.id,
	    PayInfo: '',
	    PayPic: '',
	    PayMoney: 0,
		PayType: 0,
		Money: 0,
		NoPay:0,
		OrderOrWill:2
      },
	   clineOnce:true,
	  detail: {},
	 
	  id: 0,
      header: {
        token: uni.getStorageSync('token')
      },
      height: this.but_height(),
      action: this.urlimg + 'api/Upfile/PostImgFile',
      page: 1,
      status: 'loading',
	 
      loading: true
    }
  },
  onLoad(e) {
    uni.setNavigationBarTitle({
      title: '订单审核'
    })
	    this.id = Number(e.id)
	 
	   this.$axios('api/OrderBasic/GetAllDetail', 'post', { value: this.id }).then(res => {
	   this.detail = res.Value
	   this.form.PayMoney=this.detail.deypaymoney
	   if(this.form.PayType>0)
	   {
		    this.form.PayType=this.detail.deypaytype-1
	   }
	   
	    this.form.Money=this.detail.fMoney
	 })
  },
  methods: {
    // user/submit_apply 			新增报销
    submit() {
		if (!this.clineOnce)
		{
		  uni.showToast({
		    title: '信息提交中，请勿重复提交',
		    icon: 'none',
		    duration: 2000
		  })
		  return false
		}
		this.form.PayPic = this.$api.getreqImg(this.$refs.uUpload.lists)
		
		if (!this.form.PayPic.length) {
		  uni.showToast({
		    title: '请添加订单凭证',
		    duration: 2000,
		    icon: 'none'
		  })
		  return false
		}
		
		this.clineOnce = false
	 
		  this.form.OrderId=this.id
	     this.form.PayType=parseInt(this.form.PayType)+1
		//   console.log("pic", this.$refs.uUpload.lists)
        
        this.$axios('api/OrderBasic/OfficeConfirmDetail', 'post', { value: this.form }).then(res => {
		  if (!res.Success) {
		    uni.showToast({
		      title: '提交失败：'+res.Message,
		      icon: 'none',
		      duration: 2000
		    })
			 this.clineOnce = true
		    return false
		  }
		this.clineOnce = true
        this.$api.handleToUrl('提交成功', '/pages/manage/ReportDetail?id='+this.detail.fReportId )
      })
    },
	 confirm(e) {
	 	  this.form.PayType = e.detail.value
	 	  console.log('this.form.PayType:', this.form.PayType)
	   },
	
  }
}
</script>

<style lang="scss">
.clist {
  padding: 34rpx 32rpx;
  box-sizing: border-box;
  background-color: #ffffff;
  .cname {
    width: 164rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #34404a;
  }

  .rmb {
    font-size: 30rpx;
    font-weight: 400;
    color: #34404a;
  }
}
.infos {
  padding: 0 32rpx;
  .clist {
    padding-left: 0;
    padding-right: 0;
  }
  .txt {
    height: 200rpx;
    background: #f8f9fc;
    border-radius: 16rpx;
    border: 2rpx solid rgba(0, 0, 0, 0.09);
    padding: 22rpx 20rpx;
    box-sizing: border-box;
    width: 100%;
  }
}
.h16 {
  height: 16rpx;
  background-color: #f5f7f9;
}
</style>
